package cn.edu.java.io.inputstream.filterinputstream;

import lombok.SneakyThrows;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;

public class BufferedInputStreamDemo {
    @SneakyThrows
    public static void main(String[] args) {
        // 创建文件输入流
        InputStream inputStream = new FileInputStream("input/123.txt");

        // 使用BufferedInputStream进行包装
        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);

        // 读取数据
        int data;
        while ((data = bufferedInputStream.read()) != -1) {
            System.out.print((char) data); // 假设文件中是文本数据
        }

        // 关闭流
        bufferedInputStream.close();

    }
}

